package Consulta;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

/**
 *
 * @author Jose Martinez
 */
public class DB {

    protected    Connection conn = null;
    protected  Statement stmt = null;
    protected  ResultSet rs = null;
    protected String select = null;

    public DB() {
    }

    protected  void conectarDB() {
        try {
            String url = "jdbc:mysql://edenorte.db.8522030.hostedresource.com:3306/edenorte";
            String usr = "edenorte";
            String pwd = "C@rlos071090";
            Class.forName("com.mysql.jdbc.Driver").newInstance();
            conn = DriverManager.getConnection(url, usr, pwd);
            stmt = conn.createStatement();
            } catch (InstantiationException ex) {
            Logger.getLogger(DB.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IllegalAccessException ex) {
            Logger.getLogger(DB.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(DB.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, "Error de conexion");
            System.out.println(ex);
        }
    }

    protected  void desconectarDB() {
        try {
            conn.close();
            stmt.close();
            rs.close();
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Error Desconectando");
        }
    }

    /*public static void main(String[] args) {
        DB p = new DB("");
        p.respuestaConsulta();
    }*/
}